using Lifter.Gui.Monitor.Contorls.Labels;
using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace Lifter.Gui.Monitor.Controls
{
	public class DateTimeControl : BaseControl
	{
		private LEDLabelControl ledLabelTime = new LEDLabelControl();
		private LEDLabelControl ledLabelDate = new LEDLabelControl();
		private Timer timer = new Timer();
		private int borderWith = 2;
		private IContainer components = null;
		public int BorderWith
		{
			get
			{
				return this.borderWith;
			}
			set
			{
				this.borderWith = value;
				base.Invalidate();
			}
		}
		public DateTimeControl()
		{
			this.InitializeComponent();
			this.timer.Enabled = true;
			this.timer.Interval = 1000;
			this.timer.Tick += new EventHandler(this.Timer_Tick);
		}
		protected override void OnPaint(PaintEventArgs e)
		{
			this.DrawBody(e.Graphics);
		}
		private void DrawBody(Graphics g)
		{
			if (g == null)
			{
				g = base.CreateGraphics();
			}
			g.SmoothingMode = SmoothingMode.HighQuality;
			string s = DateTime.Now.ToString("yyyy-MM-dd");
			string s2 = DateTime.Now.ToString("tt hh:mm.ss");
			Brush lavender = new SolidBrush(Color.FromArgb(85, 85, 85)); //Brushes.Lavender;
			Brush royalBlue = new SolidBrush(Color.FromArgb(85, 85, 85)); //Brushes.RoyalBlue;
			Brush black = Brushes.White;
			Rectangle rect = new Rectangle(this.borderWith, this.borderWith, base.Width - this.borderWith * 2, base.Height - this.borderWith * 2);
			base.DrawRoundRect(g, rect, 2, lavender, royalBlue, this.borderWith);
			Font font = new Font("Tahoma", 10f, FontStyle.Bold);
			StringFormat stringFormat = new StringFormat();
			stringFormat.Alignment = StringAlignment.Center;
			stringFormat.LineAlignment = StringAlignment.Center;
			g.DrawString(s, font, Brushes.White, new RectangleF(0f, 1f, (float)base.Width, (float)(base.Height / 2)), stringFormat);
			g.DrawString(s, font, Brushes.White, new RectangleF(1f, 0f, (float)base.Width, (float)(base.Height / 2)), stringFormat);
			g.DrawString(s, font, black, new RectangleF(0f, 0f, (float)base.Width, (float)(base.Height / 2)), stringFormat);
			g.DrawString(s2, font, Brushes.White, new RectangleF(0f, (float)(base.Height / 2 + 1), (float)base.Width, (float)(base.Height / 2)), stringFormat);
			g.DrawString(s2, font, Brushes.White, new RectangleF(1f, (float)(base.Height / 2), (float)base.Width, (float)(base.Height / 2)), stringFormat);
			g.DrawString(s2, font, black, new RectangleF(0f, (float)(base.Height / 2), (float)base.Width, (float)(base.Height / 2)), stringFormat);
		}
		protected override void OnPaintBackground(PaintEventArgs pevent)
		{
			base.OnPaintBackground(pevent);
		}
		private void Timer_Tick(object sender, EventArgs e)
		{
			base.Invalidate();
		}
		protected override void Dispose(bool disposing)
		{
			if (disposing && this.components != null)
			{
				this.components.Dispose();
			}
			base.Dispose(disposing);
		}
		private void InitializeComponent()
		{
		}
	}
}
